package leaderus.study;

import java.util.Date;
import java.util.HashMap;

import com.google.common.collect.Sets;

/**
 * @author lihongliang
 *
 */
public class TestMyCloneableObj {
	public static void main(String[] args) {
		MyInfo myInfo1=new MyInfo(Sets.newHashSet("test","test1"),true);
		MyInfo myInfo2=new MyInfo(Sets.newHashSet("test2","test3"),true);
		MyCloneableObj test=new MyCloneableObj();
		test.setMyId("1");
		test.setValidDate(new Date());
		HashMap<String,MyInfo> hashMap = new HashMap<String,MyInfo>();
		hashMap.put("myInfo1", myInfo1);
		hashMap.put("myInfo2", myInfo2);
		test.setMyInfos(hashMap);
		
		MyCloneableObj clone = (MyCloneableObj)test.clone();
		//比较MyCloneableObj对象和克隆对象是否相同
		System.out.println("MyCloneableObj对象和clone的对象的属性是否相同："+(test.equals(clone)));
		//比较MyCloneableObj对象和克隆对象地址是否相同
		System.out.println("MyCloneableObj对象和clone的对象的地址是否相同："+(test==clone));
		//清除某个myInfo中的enabledFeature属性
		MyInfo myInfo = clone.getMyInfos().get("myInfo1");
		myInfo.getEnabledFeature().clear();
		System.out.println("====================清除clone对象的某个myInfo后=====================");
		//比较MyCloneableObj对象和克隆对象是否相同
		System.out.println("MyCloneableObj对象和clone的对象的属性是否相同："+(test.equals(clone)));
		//比较MyCloneableObj对象和克隆对象地址是否相同
		System.out.println("MyCloneableObj对象和clone的对象的地址是否相同："+(test==clone));
		
		
		
	}
}
